export default {
	name: "create-entity",
	data() {
		return {
			colWidth: 6,
			itemWidth: 22,
			labelWidth: "90px",
			formParams: {"project": "boot-jdbc", "package": "com.broad.commerce.jdbc.models", "parent": "", "className": "", "isUpdate": false, data: []},
			firstItems: [
				{"label": "项目名", "kind": "input", "prop": "project", "isEdit": false, "disabled": false},
				{"label": "包名", "kind": "input", "prop": "package", "isEdit": false, "disabled": false},
				{"label": "父目录", "kind": "input", "prop": "parent", "isEdit": false, "disabled": false},
				{"label": "类名", "kind": "input", "prop": "className", "isEdit": false, "disabled": false}
			],
			secondItems: [
				{
					"label": "是否更新", "kind": "select", "prop": "isUpdate", "isEdit": false, "disabled": false,
					selectOptions: this.constants.select.booleanOptions
				}
			],
			columns: [
				{"label": "字段名", "prop": "fieldName", "kind": "input", "width": 360, "disabled": false},
				{"label": "字段类型", "prop": "fieldType", "kind": "input", "width": 450, "disabled": false},
				{"label": "字段注释", "prop": "fieldComment", "kind": "input", "disabled": false}
			],
			data: [
				{
					fieldName: "",
					fieldType: "",
					fieldComment: ""
				}
			],
			rules: {
				project: [
					{required: true, message: "请输入项目名称", trigger: "blur"}
				],
				package: [
					{required: true, message: "请输入包名", trigger: "blur"}
				],
				parent: [
					{required: true, message: "请输入父目录", trigger: "blur"}
				],
				className: [
					{required: true, message: "请输入类名", trigger: "blur"}
				],
				isUpdate: [
					{required: true, message: "请选择是否更新类", trigger: "blur"}
				]
			}
		};
	},
	created() {
	},
	methods: {
		handleSave() {
			this.formParams.data = this.data;
			console.log(this.formParams);
		},
		appendRow(rowIndex) {
			this.data.push({
				fieldName: "",
				fieldType: "",
				fieldComment: ""
			});
		},
		removeRow(rowIndex) {
			if (rowIndex === 0) {
				return;
			}
			this.data.splice(rowIndex, 1);
		}
	}
};
